import React, { Component } from "react";
import { View, WebView, Linking } from "react-native";
import Header from "../Components/Header";

export class ViewPacs extends Component {
  render() {
    const { navigation } = this.props;
    const accessionNumber = navigation.getParam("accessionNumber");
    const uri = `http://103.71.65.184/Launch_Viewer.asp?AccessionNumber=${accessionNumber}&Username=hisuser&Password=hisuser`;
    return (
      <View style={{ flex: 1 }}>
        <Header text="View Pacs" isBack={true} />
        <WebView
          ref={ref => {
            this.webview = ref;
          }}
          useWebKit={true}
          startInLoadingState={true}
          style={{ flex: 1 }}
          scrollEnabled={true}
          shouldRasterizeIOS={false}
          source={{
            uri
          }}
          javaScriptEnabled={true}
          onNavigationStateChange={event => {
            if (
              event.url !== "http://103.71.65.184/Launch_Viewer.asp" ||
              event.url !== uri
            ) {
              Linking.openURL(event.url);
            }
          }}
        />
      </View>
    );
  }
}

export default ViewPacs;
